package com.amazon.spring8amazon.common;

import org.apache.tomcat.util.http.fileupload.FileUtils;
import org.aspectj.util.FileUtil;

import java.io.*;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.sql.*;

/**
 * 读取指定文件下sql脚本，执行到数据库
 * 朱行读取分批处理批量插入数据库
 */
public class TestReadFile {


    public static String readFile(String fileName) throws IOException {
        BufferedReader reader = new BufferedReader(new FileReader(fileName));
        StringBuilder sb = new StringBuilder();
        String line;
        while ((line = reader.readLine()) != null) {
            //去掉行注释
            if (line.toString().startsWith("--")) {
                continue;
            }
            // 追加
            sb.append(line).append(" ");
        }
        reader.close();
        return sb.toString();
    }


}
